<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
    <head>
        <title>TODO supply a title</title>
        <script>
            function trim(s) 
            {
                return s.replace( /^s*/, "" ).replace( /s*$/, "" );
            }

            function validate()
            {
                if(trim(document.frmChangePass.oldPassword.value)==="")
                {
                    alert("OldPassword, NewPassword and ConfirmPassword cannot be empty. Please enter!");
                    document.frmChangePass.oldPassword.focus();
                    return false;
                }else if (trim(document.frmChangePass.newPassword.value)==="")
                    {
                        alert("NewPassword and ConfirmPassword cannot be empty. Please enter!");
                        document.frmChangePass.newPassword.focus();
                        return false;
                }else if(trim(document.frmChangePass.confirmPassword.value)==="")
                    {
                        alert("ConfirmPassword cannot be empty. Please enter!");
                        document.frmChangePass.confirmPassword.focus();
                        return false;
                }else if(trim(document.frmChangePass.oldPassword.value)===trim(document.frmChangePass.newPassword.value))
                {
                    alert("NewPassword cannot be the same as OldPassword. Please enter!");
                    document.frmChangePass.newPassword.focus();
                    return false;
                }else if(trim(document.frmChangePass.newPassword.value)!==trim(document.frmChangePass.confirmPassword.value))
                {
                    alert("ConfirmPassword must be the same as NewPassword. Please enter!");
                    document.frmChangePass.confirmPassword.focus();
                    return false;
                }
            }
        </script>
    </head>
    <body>
        <ui:composition template="/admin/templates/indexTemplate.xhtml">
            <ui:define name="main">
                <div class="full_w">
                    <c:set var="item" value="${requestScope.result}"/>
                    <c:if test="${!empty item}" >
                        <label style="color: #FF5252; font-size: 30">${result}</label>
                    </c:if>
                    <div class="h_title">Edit Password</div>
                    <form name="frmChangePass" action="Admin_changePass" method="post" onsubmit="return validate();">
                            <div class="element">
                                    <label for="name">Old Password </label>
                                    <input id="name" name="oldPassword" type="password" class="text" />
                            </div>
                            <div class="element">
                                    <label for="name">New Password </label>
                                    <input id="name" name="newPassword" type="password" class="text" />
                            </div>
                            <div class="element">
                                        <label for="name">Confirm New Password </label>
                                        <input id="name" name="confirmPassword" type="password" class="text" />
                                </div>
                            <div class="entry">
                                <button type="submit" class="add">Change</button> <button type="reset" class="reset">Reset</button>
                            </div>
                    </form>
            </div>
            </ui:define>
        </ui:composition>
    </body>
</html>
